package com.xintai.system.controller;

import java.util.List;

import com.xintai.utils.StaticString;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.system.domain.PubJijianerji;
import com.xintai.system.service.IPubJijianerjiService;
import com.xintai.common.utils.poi.ExcelUtil;
import com.xintai.common.core.page.TableDataInfo;

/**
 * 生产线基建，二级项目Controller
 * 
 * @author xintai
 * @date 2020-12-23
 */
@RestController
@RequestMapping("/system/jijianerji")
public class PubJijianerjiController extends BaseController
{
    @Autowired
    private IPubJijianerjiService pubJijianerjiService;

    /**
     * 查询生产线基建，二级项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:list')")
    @GetMapping("/list")
    public TableDataInfo list(PubJijianerji pubJijianerji)
    {
        startPage();
        List<PubJijianerji> list = pubJijianerjiService.selectPubJijianerjiList(pubJijianerji);
        return getDataTable(list);
    }

    /**
     * 导出生产线基建，二级项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:export')")
    @Log(title = "生产线基建，二级项目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PubJijianerji pubJijianerji)
    {
        List<PubJijianerji> list = pubJijianerjiService.selectPubJijianerjiList(pubJijianerji);
        ExcelUtil<PubJijianerji> util = new ExcelUtil<PubJijianerji>(PubJijianerji.class);
        return util.exportExcel(list, "jijianerji");
    }

    /**
     * 获取生产线基建，二级项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:query')")
    @GetMapping(value = "/{jjId}")
    public AjaxResult getInfo(@PathVariable("jjId") Long jjId)
    {
        return AjaxResult.success(pubJijianerjiService.selectPubJijianerjiById(jjId));
    }

    /**
     * 新增生产线基建，二级项目
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:add')")
    @Log(title = "生产线基建，二级项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PubJijianerji pubJijianerji)
    {
        if (pubJijianerjiService.verifyPubJijianerji(pubJijianerji))
            return AjaxResult.error(StaticString.NameRepeat(pubJijianerji.getJjName()));
        return toAjax(pubJijianerjiService.insertPubJijianerji(pubJijianerji));
    }

    /**
     * 修改生产线基建，二级项目
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:edit')")
    @Log(title = "生产线基建，二级项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PubJijianerji pubJijianerji)
    {
        if (pubJijianerjiService.verifyPubJijianerji(pubJijianerji))
            return AjaxResult.error(StaticString.NameRepeat(pubJijianerji.getJjName()));
        return toAjax(pubJijianerjiService.updatePubJijianerji(pubJijianerji));
    }

    /**
     * 删除生产线基建，二级项目
     */
    @PreAuthorize("@ss.hasPermi('system:jijianerji:remove')")
    @Log(title = "生产线基建，二级项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jjIds}")
    public AjaxResult remove(@PathVariable Long[] jjIds)
    {
        return toAjax(pubJijianerjiService.deletePubJijianerjiByIds(jjIds));
    }
}
